<template>
    <div>
        <component :is="`Type${data_type}`" :externalData="externalData"></component>
    </div>
</template>
<script>
const Type1 = () => import('@/views/home/operate-panel/booking-management/booking-index') // 预约保养
const Type2 = () => import('@/views/home/operate-panel/newCar-group/sign-up-info')        // 新车团购
const Type8 = () => import('@/views/home/operate-panel/afterSell-group/sign-up-info')     // 售后团购
const Type3 = () => import('@/views/home/operate-panel/goods-management/reg-info')
const Type4 = () => import('@/views/home/operate-panel/car-test/integral-list-table')
const Type5 = () => import('@/views/home/ytcars-panel/inquiry-customer/inquiry')
const Type6 = () => import('./details_3')
const Type7_4 = () => import('@/views/home/operate-panel/points-mall/points-order/order-list')
const Type7_5 = () => import('@/views/home/operate-panel/order-statistics/order-statistics-index')
const Type9 = () => import('./details_9')

export default {
    data() {
        return {
            data_type: 1,
            data_label: '数据明细',
            externalData: {} // 用于更新引入的组件数据
        }
    },
    components: {
        Type1,
        Type2,
        Type3,
        Type4,
        Type5,
        Type6,
        Type7_4,
        Type7_5,
        Type8,
        Type9
    },
    created() {
        const data_type = this.$route.query.data_type;
        const data_label = this.$route.query.data_label;
        if(data_type) this.data_type = data_type;
        if(data_label) this.data_label = data_label + "详情";
        this.externalData = {
            comePage: 'transaction-data-details', // 来源页面
            // originate: 8, // 来源默认为小程序
            filter_not_yt: 1
        }
        if (this.$route.query.is_valid) {
            this.externalData.is_valid = this.$route.query.is_valid
        }
        if(!this.$parent.tabLists.find(item => item.name == "transactionDataDetails")) {
            this.$parent.tabLists.push({
                label: this.data_label, name: "transactionDataDetails"
            })
        }
    },
    beforeRouteLeave (to, from, next) {
        this.$parent.tabLists = this.$parent.tabLists.filter(item => item.name != "transactionDataDetails")
        next()
    }
}
</script>